/*
   @Copyright:LeetCode
   @Author:   tjyemail
   @Problem:  http://leetcode.com/problems/gray-code
   @Language: C++
   @Datetime: 19-07-08 15:27
   */

class Solution {
public:
	vector<int> grayCode(int n) {
		vector<int> v((1<<n),0);
		for(int i=1<<n; i--; v[i]=i^(i>>1));
		return v;
	}
};
